<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
			$(function(){
				$("#btnSearch").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        }).click(function(){
		        	dateFormat(document.getElementById("chequeDate"));
					if(validateEmpty()){
						$("#searchForm").submit();
					} else {
						return false;
					}
				});
				$("#btnEdit").button({
		            icons: {
		                primary: "ui-icon-disk"
		            }
		        }).click(function(){
					$("#job").val("update");
		        	$("#searchForm").submit();
				});
		        thaiDatepicker("chequeDate","#","1");
		        thaiDatepicker("expenseDate","#","1");
			});
		</script>
	</head>
	<body>
		<c:set var="auth" value="${el:getMapValue(menuAuth, 'ACC60501')}"/>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc6" method="post">
		<input type="hidden" name="app" id="app" value="ACC60501"/>
		<input type="hidden" name="job" id="job" value="search"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC60501}</b></th>
			</tr>
			<tr>
				<td class="bold" width="20%">จังหวัด : </td>
				<td>
					<select name="provinceId" id="provinceId">
						<option value="">----- เลือก -----</option>
							<c:forEach var="data" items="${listProvince}">
							<c:if test="${data.PROVINCE_ID == provinceId}" var="provinceSeleted"/>
							<option value="${data.PROVINCE_ID}" ${provinceSeleted?'selected':''}>${data.PROVINCE_NAME}</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<%-- <tr>
				<td class="bold">วันที่ทำรายการ : </td>
				<td>
					<input type="text" name="expenseDate" id="expenseDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${expenseDate}"/>
					<span id="#expenseDate" class="red">*</span>
				</td>
			</tr> --%>
			<tr>
				<td class="bold">วันที่สั่งจ่าย : </td>
				<td>
					<input type="text" name="chequeDate" id="chequeDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${chequeDate}"/>
					<!-- <span id="#chequeDate" class="red">*</span> -->
				</td>
			</tr>
			<tr>
				<td class="bold">เลขที่ cheque : </td>
				<td>
					<input type="text" name="chequeNo" id="chequeNo" maxlength="8" onkeypress="return numberAndDot(event, false);" value="${chaqueNo}">
					<!-- <span id="#chequeNo" class="red">*</span> -->
				</td>
			</tr>
			<tr>
				<td class="bold">สถานะ : </td>
				<td>
					<input type="radio" name="status" id="succeed" value="succeed" ${status=='succeed'?'checked':''}/> ขึ้นเงินแล้ว
					<input type="radio" name="status" id="fail" value="fail" ${status=='fail'?'checked':''}/> ไม่ขึ้นเงิน
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<button type="button" name="btnSearch" id="btnSearch" class="acc67-button"> ค้นหาข้อมูล </button>
				</td>
			</tr>
		</table>
		<br/>
		<c:if test="${!empty listData}">
			<fieldset>
				<legend> แสดงรายการข้อมูล Chaque </legend>
				<br/>
					<table width="100%" class="acc67-grid ui-widget ui-widget-content" border="0">
						<tr>
							<th align="center" class="ui-state-default">เลขที่ Chaque</th>
							<th align="center" class="ui-state-default">สสจ. </th>
							<th align="center" class="ui-state-default">หน่วยบิรการ/คู่สัญญา</th>
							<th align="center" class="ui-state-default">จำนวนเงิน</th>
							<th align="center" class="ui-state-default">วันที่ตัดยอดบัญชี</th>
						</tr>
						<c:forEach items="${listData}" var="data" varStatus="x">
							<tr class="grid-tr-${x.count % 2}">
								<td align="center">${data.chequeNo}</td>
								<td align="left">${el:getDataUtil('PAN', data.provinceId)}</td>
								<td align="left">${el:getDataUtil('VN',data.venderCode)}</td>
								<td align="right"><fmt:formatNumber pattern="#,##0.00" value="${data.expenseAmount}" /></td>
								<td align="center">
									<c:if test="${data.reasonCode != '00' && fn:contains(auth, 'U')}" var="disabled"/>
									<input type="text" name="chequeReceivingDate" ${disabled?'class=chequeReceivingDate':'disabled'} id="chequeReceivingDate${x.count}" value="${el:dateTh(data.chequeReceivingDate)}"/>
									<script>
							        	thaiDatepicker("chequeReceivingDate${x.count}","#","1");
									</script>
									<c:if test="${data.reasonCode != '00'}">
										<input type="hidden" name="transactionTimestamp" value="${data.transactionTimestamp}"/>
									</c:if>
								</td>
							</tr>
						</c:forEach>
						<c:if test="${fn:contains(auth, 'U')}">
							<tr>
								<td colspan="5" align="center">
									<button class="acc67-button" name="btnEdit" id="btnEdit" type="button" >บันทึก</button>
								</td>
							</tr>
						</c:if>
					</table>
			</fieldset>
		</c:if>
		</form>
	</body>
</html>